package com.baizhi.service.impl;

import com.baizhi.dao.CategoryDao;
import com.baizhi.entity.Category;
import com.baizhi.service.CategoryService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CategoryServiceImpl implements CategoryService {
    private CategoryDao categoryDao;

    public void setCategoryDao(CategoryDao categoryDao) {
        this.categoryDao = categoryDao;
    }

    @Override
    public int addCateogry(Category c) {
        int  i = categoryDao.insertCategory(c);
        return i;
    }

    @Override
    public int updateCategory(Category c) {
        int  i = categoryDao.updateCategory(c);
        return i;
    }

    @Override
    public List<Category> selectAllCategory() {
        List<Category> list = categoryDao.selectAllCategory();
        return list;
    }

    @Override
    public List<Category> selectCategoryByCondition(Integer pageNum, Integer pageSize) {
        Integer start = (pageNum-1)*pageSize;
        List<Category> list = categoryDao.selectCategoryByCondition(start, pageSize);
        return list;
    }

    @Override
    public int totalCategory() {
        int i = categoryDao.totalCategory();
        return i;
    }

    @Override
    public Category selectById(Integer id) {
        Category category = categoryDao.selectById(id);
        return category;
    }
}
